import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/home/home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    alias: '/home',
    component: Home,
    meta: {
      footShow: true
    }
  },
  {
    path: '/kind',
    name: 'Kind',
    component: () => import(/* webpackChunkName: "kind" */ '../views/kind/kind.vue'),
    meta: {
      footShow: true
    }
  },
  {
    path: '/cart',
    name: 'Cart',
    component: () => import(/* webpackChunkName: "cart" */ '../views/cart/cart.vue'),
    meta: {
      footShow: false
    },
    beforeEnter (to, from, next) {
      if (sessionStorage.getItem('isLogin') === 'ok') {
        next()
      } else {
        next('/login')
      }
    }
  },
  {
    path: '/my',
    name: 'My',
    component: () => import(/* webpackChunkName: "my" */ '../views/my/my.vue'),
    meta: {
      footShow: true
    },
    beforeEnter (to, from, next) {
      if (sessionStorage.getItem('isLogin') === 'ok') {
        next()
      } else {
        next('/login')
      }
    }
  },
  {
    path: '/detail/:id',
    name: 'Detail',
    component: () => import(/* webpackChunkName: "cart" */ '../views/detail/detail.vue'),
    meta: {
      footShow: false
    },
    props: true
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import(/* webpackChunkName: "user" */ '../views/login/login.vue'),
    meta: {
      footShow: false
    }
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import(/* webpackChunkName: "user" */ '../views/register/register.vue'),
    meta: {
      footShow: false
    }
  },
  {
    path: '/order',
    name: 'Order',
    component: () => import(/* webpackChunkName: "order" */ '../views/order/order.vue'),
    meta: {
      footShow: false
    }
  },
  {
    path: '/area',
    name: 'Area',
    component: () => import(/* webpackChunkName: "order" */ '../views/area/area.vue'),
    meta: {
      footShow: false
    },
    beforeEnter (to, from, next) {
      if (sessionStorage.getItem('isLogin') === 'ok') {
        next()
      } else {
        next('/login')
      }
    }
  },
  {
    path: '/addArea',
    name: 'AddArea',
    component: () => import(/* webpackChunkName: "order" */ '../views/addArea/addArea.vue'),
    meta: {
      footShow: false
    },
    beforeEnter (to, from, next) {
      if (sessionStorage.getItem('isLogin') === 'ok') {
        next()
      } else {
        next('/login')
      }
    }
  },
  {
    path: '/setMsg',
    name: 'SetMsg',
    component: () => import(/* webpackChunkName: "order" */ '../views/setMsg/setMsg.vue'),
    meta: {
      footShow: false
    }
  },
  {
    path: '/search',
    name: 'Search',
    component: () => import(/* webpackChunkName: "order" */ '../views/search/search.vue'),
    meta: {
      footShow: false
    }
  },
  {
    path: '/searchRes/:s/:t',
    name: 'SearchRes',
    component: () => import(/* webpackChunkName: "order" */ '../views/searchRes/searchRes.vue'),
    meta: {
      footShow: false
    },
    props: true
  },
  {
    path: '/evaluate/:s',
    name: 'Evaluate',
    component: () => import(/* webpackChunkName: "order" */ '../views/evaluate/evaluate.vue'),
    meta: {
      footShow: false
    },
    props: true
  }
]

const router = new VueRouter({
  routes
})

export default router
